/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "InvPSOLines")
@XmlRootElement
public class InvPSOLines implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ipsoID")
    private Integer invPSOID;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ipsoQty")
    private int invPSOQty;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ipsoSold")
    private boolean invPSOSold;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ipsoPriceOver")
    private float invPSOPriceOver;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ipsoQtyLeft")
    private int invPSOQtyLeft;
    @JoinColumn(name = "ipsoSupplyID", referencedColumnName = "SupID")
    @ManyToOne(optional = false)
    private Supplies invPSOSupplyID;
    @JoinColumn(name = "ipsoDisc", referencedColumnName = "DiscID", nullable=true)
    @ManyToOne(optional = false)
    private DiscountCode invPSOdisc;

    public InvPSOLines() {
    }

    public InvPSOLines(Integer invPSOID) {
        this.invPSOID = invPSOID;
    }

    public InvPSOLines(Integer invPSOID, int invPSOQty, boolean invPSOSold, float invPSOPriceOver, int invPSOQtyLeft) {
        this.invPSOID = invPSOID;
        this.invPSOQty = invPSOQty;
        this.invPSOSold = invPSOSold;
        this.invPSOPriceOver = invPSOPriceOver;
        this.invPSOQtyLeft = invPSOQtyLeft;
    }

    public Integer getInvPSOID() {
        return invPSOID;
    }

    public void setInvPSOID(Integer invPSOID) {
        this.invPSOID = invPSOID;
    }

    public int getInvPSOQty() {
        return invPSOQty;
    }

    public void setInvPSOQty(int invPSOQty) {
        this.invPSOQty = invPSOQty;
    }

    public boolean isInvPSOSold() {
        return invPSOSold;
    }

    public void setInvPSOSold(boolean invPSOSold) {
        this.invPSOSold = invPSOSold;
    }

    public float getInvPSOPriceOver() {
        return invPSOPriceOver;
    }

    public void setInvPSOPriceOver(float invPSOPriceOver) {
        this.invPSOPriceOver = invPSOPriceOver;
    }

    public int getInvPSOQtyLeft() {
        return invPSOQtyLeft;
    }

    public void setInvPSOQtyLeft(int invPSOQtyLeft) {
        this.invPSOQtyLeft = invPSOQtyLeft;
    }

    public Supplies getInvPSOSupplyID() {
        return invPSOSupplyID;
    }

    public void setInvPSOSupplyID(Supplies invPSOSupplyID) {
        this.invPSOSupplyID = invPSOSupplyID;
    }

    public DiscountCode getInvPSOdisc() {
        return invPSOdisc;
    }

    public void setInvPSOdisc(DiscountCode invPSOdisc) {
        if(invPSOdisc.getDiscID()!=null){
            this.invPSOdisc = invPSOdisc;
        }
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (invPSOID != null ? invPSOID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sales)) {
            return false;
        }
        InvPSOLines other = (InvPSOLines) object;
        if ((this.invPSOID == null && other.invPSOID != null) || (this.invPSOID != null && !this.invPSOID.equals(other.invPSOID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.InvPSOLines[ ipsoID=" + invPSOID + " ]";
    }
}
